﻿namespace RockPaperScissors.Web.Utility.Tests
{
    using NUnit.Framework;
    using RockPaperScissors.Core;
    
    [TestFixture]
    public class RoundWinnerTests
    {
        [Test]
        public void Should_Return_True_When_Team_One_Has_Amout_Of_Wins_To_Win_Match()
        {
            Record teamOneRecord = new Record() { Wins = CompeteHelper.BEST_OF, Losses = 0, Ties = 1 };
            Record teamTwoRecord = new Record() { Wins = 5, Losses = 0, Ties = 1};

            bool result = CompeteHelper.HaveRoundWinner(teamOneRecord, teamTwoRecord);

            Assert.IsTrue(result);
        }

        [Test]
        public void Should_Return_True_When_Team_Two_Has_Amout_Of_Wins_To_Win_Match()
        {
            Record teamOneRecord = new Record() { Wins = 5, Losses = 0, Ties = 1 };
            Record teamTwoRecord = new Record() { Wins = CompeteHelper.BEST_OF, Losses = 0, Ties = 1 };

            bool result = CompeteHelper.HaveRoundWinner(teamOneRecord, teamTwoRecord);

            Assert.IsTrue(result);
        }

        [Test]
        public void Should_Return_False_When_Both_Teams_Have_No_Wins()
        {
            Record teamOneRecord = new Record() { Wins = 0, Losses = 0, Ties = 0 };
            Record teamTwoRecord = new Record() { Wins = 0, Losses = 0, Ties = 0 };

            bool result = CompeteHelper.HaveRoundWinner(teamOneRecord, teamTwoRecord);

            Assert.IsFalse(result);
        }

        [Test]
        public void Should_Return_False_When_Both_Teams_Have_5_Wins()
        {
            Record teamOneRecord = new Record() { Wins = 5, Losses = 0, Ties = 0 };
            Record teamTwoRecord = new Record() { Wins = 5, Losses = 0, Ties = 0 };

            bool result = CompeteHelper.HaveRoundWinner(teamOneRecord, teamTwoRecord);

            Assert.IsFalse(result);
        }

        [Test]
        public void Should_Return_False_When_Both_Teams_Have_8_Ties()
        {
            Record teamOneRecord = new Record() { Wins = 0, Losses = 0, Ties = 8 };
            Record teamTwoRecord = new Record() { Wins = 0, Losses = 0, Ties = 8 };

            bool result = CompeteHelper.HaveRoundWinner(teamOneRecord, teamTwoRecord);

            Assert.IsFalse(result);
        }
    }
}